package org.keyintegrity.webbeans.demo;

import org.apache.tapestry.components.Block;
import org.apache.tapestry.html.BasePage;
import org.keyintegrity.webbeans.demo.beans.ComplexJavaBean;
import org.keyintegrity.webbeans.demo.beans.DemoBeans;
import org.keyintegrity.webbeans.demo.beans.PlainJavaBean;

public abstract class BeanEditorDemo extends BasePage {

    private PlainJavaBean plainJavaBean;
    private ComplexJavaBean complexJavaBean;
    
    public abstract Block getActiveBlock();
    public abstract void setActiveBlock(Block block);
    
    public Block getPlainJavaBeanDemo() {
        return (Block) getComponent("plainJavaBeanDemo");
    }

    public void showBlock(String blockId) {
        setActiveBlock((Block) getComponent(blockId));
    }
    
    public PlainJavaBean getPlainJavaBean() {
        if (plainJavaBean == null) {
            plainJavaBean = DemoBeans.getPlainJavaBean();
        }
        return plainJavaBean;
    }
    
    public ComplexJavaBean getComplexJavaBean() {
        if (complexJavaBean == null) {
            complexJavaBean = DemoBeans.getComplexJavaBean();
        }
        return complexJavaBean;
    }
}
